﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Crank.Core
{
    static class IncludePreprocessor
    {
        #region Blackboard Variables

        private static readonly IProperty<IList<string>> Files = Blackboard.Create<IList<string>>("Files");

        #endregion

        public static void Install()
        {
            Files.Value = new List<string>();
            Preprocessor.AddDirective("include", Process);
        }

        private static void Process(string[] args)
        {
            if (args.Length != 1)
                throw new Exception("Cannot have a space in an include");
            string fileName = args[0].ToLower();
            if (!fileName.EndsWith(".cal"))
                fileName += ".cal";
            Files.Value.Add(fileName);
        }
    }
}
